package com.pai4j.aigc.context.repository.dao;

import com.pai4j.aigc.context.entity.ChatSessionEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;

import java.util.Optional;

@Repository
public interface IChatSessionDAO extends JpaSpecificationExecutor<ChatSessionEntity>, JpaRepository<ChatSessionEntity, Long> {

    Optional<ChatSessionEntity> findBySessionId(String sessionId);

    Optional<ChatSessionEntity> findFirstByUserIdAndBotIdAndStatusOrderByUpdateDateDesc(String userId, String botId, Integer status);

    Page<ChatSessionEntity> findByUserId(String userId, Pageable pageable);

    Page<ChatSessionEntity> findByUserIdAndBotId(String userId, String botId, Pageable pageable);
}
